<template>
	<view>
		<image src="../../static/logo.png" mode="" style="width: 300rpx; height: 300rpx;"></image>
		<view class="user_name">admin</view>
		<view class="">
			<hjx-login></hjx-login>
		</view>
		<view class="">
			<button @tap="logout">退出登录</button>
			<button  @tap="gotoPay">我的订单</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				token: ''
			}
		},
		onShow() {
			this.token = uni.getStorageSync('token');
			if (!this.token) {
				uni.reLaunch({
					url: '../../subpkg2/login/login'
				})
			}
		},
		methods: {
			// 退出登录
			async logout() {
				const [err, succ] = await uni.showModal({
					title: '提示',
					content: '确定退出登录吗?'
				}).catch(err => err);
				if (succ && succ.confirm) {
					uni.removeStorageSync('token');
					uni.removeStorageSync('address');
					uni.removeStorageSync('userInfo');
					uni.setStorageSync('page', 'user');
					uni.reLaunch({
						url: '../../subpkg2/login/login'
					})
				}
			},

			// 跳到订单查询页
			gotoPay() {
				uni.navigateTo({
					url: '../../subpkg2/order/order'
				})
			}
		},
		}
</script>

<style>

</style>